import Dialog from '@vant/weapp/dialog/dialog';
import { request } from '../../assets/js/request.js';
Page({
  _handlerLogout:function(){
    Dialog.confirm({
      title: '提醒',
      message: '是否要退出当前账号'
    }).then(() => {
      wx.removeStorageSync('uid');
      wx.removeStorageSync('status');
      this.setData({
        uid: '',
        uname: '',
        surname: '',
        loading: false
      })
    }).catch(() => {
      
    });
  },

  getUerPermissions:function(){
    wx.openSetting({
      success: (res) => {
        console.log(res)
      },
      fail: (err) => {
        console.log(err)
      }
    })
  },

  data: {
    status:'',
    loading: false,
    uid:'',
    uname:'',
    surname:''
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var value = wx.getStorageSync('uid');
    if (value != '') {
      this.setData({
        uid: value,
        status: wx.getStorageSync('status'),
        loading: true
      })
      request('/getName.php', { uid: this.data.uid, status: this.data.status})
        .then((res)=>{
          this.setData({
            uname: res.data.uname,
            surname: res.data.uname.substring(0,1)
          })
        })
    }
  }

})